package ua.com.fesvlast.hotel.model.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateFormatter {
	private static 	String datePatern="yyyy-MM-dd HH:mm:ss";
	
	public static String getCurrentFormatDate(){
	
		Date date =Calendar.getInstance().getTime();
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat(datePatern);
		String str =simpleDateFormat.format(date);
		
		return str;
	}
	
	public static long countTimeBetweenDatesInDays(String arrivalTime, String departureTime){
		long result=0;
		try {
			Date arrivalDate =new SimpleDateFormat(datePatern).parse(arrivalTime);
			long arrTime =arrivalDate.getTime();
			Date departureDate=new SimpleDateFormat(datePatern).parse(departureTime);
			long depTime =(long)departureDate.getTime();
			
			long sub=(long)depTime-arrTime;
			result=sub/(60L*24L*60L*1000);	
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	public static String getFormatDateString(Date currentDate){
		String datePatern="yyyy-MM-dd HH:mm:ss";
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat(datePatern);
		String str =simpleDateFormat.format(currentDate);
		return str;
	}

}
